define(["../common"], function() {
	var delDoPath = g_shopDomain + "/storeMember/delDo/json";
	var smId = $("#smId").val();

	// 事件：删除店铺管理员
	$(document).on("click", "[id^='del_']", function() {
		var id = ($(this).attr("id").split("_"))[1];// memberId
		var $item = $("#item_" + id);
		if ($item.doing()) return;
		
		var message;
		if (id === smId) {
			message = "确定要删除自己吗？<br/>删除后您将不再拥有该店铺的管理权限！";
		} else {
			var delMemberName = $("#memberName_" + id).html();
			message = "确定要删除管理员 " + delMemberName + " 吗？";
		}
		var msgConfig = {
			id: "del_" + id,
			type: 'confirm',
			content: message,
			title: "提示",
			onClose: function() {
				if (this.val()) {
					$item.showMsg("正在删除...", 'load', true);
					$item.fadeTo(null,0.1);
					// (ie兼容) 加r=Math.random()
					$.getJSON(delDoPath + "?r=" + Math.random(), {memberId: id}, function(data) {
						if (data.status === 0) {
							if (id === smId) {
								location.href = g_domain + "/member/logoutDo";
							} else {
								$item.showMsg();
								$item.fadeOut(function() {$(this).remove();});
							}
						} else {
							$item.showMsg(data.message, 'error');
							$item.fadeTo('fast',1);
						}
					});
				}
			}
		};
		loadjs(["msgbox"], function() {
			$.msgbox(msgConfig);
		});
		
	});
});
